5
5
AddKbMediaFlow
6
6
from playwright_tests .messages .explore_help_articles .kb_article_page_messages import (
7
7
KBArticlePageMessages )
8
+ from playwright_tests .pages .explore_help_articles .articles .kb_article_page import KBArticlePage
9
+ from playwright_tests .pages .explore_help_articles .articles .kb_article_review_revision_page import \
10
+ KBArticleReviewRevisionPage
11
+ from playwright_tests .pages .explore_help_articles .articles .kb_article_show_history_page import \
12
+ KBArticleShowHistoryPage
13
+ from playwright_tests .pages .explore_help_articles .articles .kb_edit_article_page import \
14
+ EditKBArticlePage
8
15
from playwright_tests .pages .explore_help_articles .articles .submit_kb_article_page import (
9
16
SubmitKBArticlePage )
10
17
11
18
12
- class AddKbArticleFlow (TestUtilities , SubmitKBArticlePage , AddKbMediaFlow ):
19
+ class AddKbArticleFlow (TestUtilities , SubmitKBArticlePage , AddKbMediaFlow , KBArticlePage ,
20
+ KBArticleShowHistoryPage , KBArticleReviewRevisionPage , EditKBArticlePage ):
13
21
14
22
def __init__ (self , page : Page ):
15
23
super ().__init__ (page )
@@ -29,7 +37,8 @@ def submit_simple_kb_article(self,
29
37
is_template = False ,
30
38
expiry_date = None ,
31
39
restricted_to_groups : list [str ] = None ,
32
- single_group = ""
40
+ single_group = "" ,
41
+ approve_first_revision = False
33
42
) -> dict [str , Any ]:
34
43
self ._page .goto (KBArticlePageMessages .CREATE_NEW_KB_ARTICLE_STAGE_URL )
35
44
@@ -62,30 +71,38 @@ def submit_simple_kb_article(self,
62
71
63
72
if article_category is None :
64
73
if is_template :
74
+ article_category = kb_article_test_data ["kb_template_category" ]
65
75
super ()._select_category_option_by_text (
66
- kb_article_test_data [ "kb_template_category" ]
76
+ article_category
67
77
)
68
78
else :
69
- super ()._select_category_option_by_text (kb_article_test_data ["category_options" ])
79
+ article_category = kb_article_test_data ["category_options" ]
80
+ super ()._select_category_option_by_text (article_category )
70
81
else :
71
82
super ()._select_category_option_by_text (article_category )
72
83
73
84
if not allow_translations :
74
85
super ()._check_allow_translations_checkbox ()
75
86
87
+ relevancy = kb_article_test_data ["relevant_to_option" ]
76
88
if selected_relevancy is True :
77
89
super ()._click_on_a_relevant_to_option_checkbox (
78
- kb_article_test_data [ "relevant_to_option" ]
90
+ relevancy
79
91
)
80
92
93
+ article_topic = [
94
+ kb_article_test_data ["selected_parent_topic" ],
95
+ kb_article_test_data ["selected_child_topic" ]
96
+ ]
97
+
81
98
# Adding Article topic
82
99
if selected_topics is True :
83
100
super ()._click_on_a_particular_parent_topic (
84
- kb_article_test_data [ "selected_parent_topic" ]
101
+ article_topic [ 0 ]
85
102
)
86
103
super ()._click_on_a_particular_child_topic_checkbox (
87
- kb_article_test_data [ "selected_parent_topic" ],
88
- kb_article_test_data [ "selected_child_topic" ],
104
+ article_topic [ 0 ],
105
+ article_topic [ 1 ],
89
106
)
90
107
91
108
# Interacting with Allow Discussion checkbox
@@ -127,6 +144,7 @@ def submit_simple_kb_article(self,
127
144
'document.getElementById("id_slug").value'
128
145
)
129
146
147
+ first_revision_id = None
130
148
if submit_article is True :
131
149
# If title and slug are empty we are not reaching the description field.
132
150
if ((article_title != '' ) and (article_slug != '' ) and (
@@ -136,19 +154,122 @@ def submit_simple_kb_article(self,
136
154
kb_article_test_data ["changes_description" ]
137
155
)
138
156
super ()._click_on_changes_submit_button ()
157
+ try :
158
+ first_revision_id = super ()._get_last_revision_id ()
159
+ except IndexError :
160
+ print ("Chances are that the form was not submitted successfully" )
139
161
else :
140
162
super ()._click_on_submit_for_review_button ()
141
163
142
164
article_url = super ()._get_article_page_url ()
143
165
166
+ if approve_first_revision :
167
+ super ()._click_on_show_history_option ()
168
+ self .approve_kb_revision (first_revision_id )
169
+
144
170
return {"article_title" : kb_article_title ,
145
171
"article_content" : kb_article_test_data ["article_content" ],
146
172
"article_content_html" : kb_article_test_data ['article_content_html_rendered' ],
147
173
"article_slug" : slug ,
148
174
"article_child_topic" : kb_article_test_data ["selected_child_topic" ],
175
+ "article_category" : article_category ,
176
+ "article_relevancy" : relevancy ,
177
+ "article_topic" : article_topic ,
149
178
"article_review_description" : kb_article_test_data ["changes_description" ],
150
179
"keyword" : kb_article_test_data ["keywords" ],
151
180
"search_results_summary" : kb_article_test_data ["search_result_summary" ],
152
181
"expiry_date" : kb_article_test_data ["expiry_date" ],
153
- "article_url" : article_url
182
+ "article_url" : article_url ,
183
+ "first_revision_id" : first_revision_id
184
+ }
185
+
186
+ def approve_kb_revision (self , revision_id : str ,
187
+ revision_needs_change = False ,
188
+ ready_for_l10n = False ):
189
+ if (KBArticlePageMessages .KB_ARTICLE_HISTORY_URL_ENDPOINT not in
190
+ super ()._get_current_page_url ()):
191
+ super ()._click_on_show_history_option ()
192
+
193
+ super ()._click_on_review_revision (
194
+ revision_id
195
+ )
196
+ super ()._click_on_approve_revision_button ()
197
+
198
+ if revision_needs_change :
199
+ if not super ()._is_needs_change_checkbox_checked ():
200
+ super ()._click_on_needs_change_checkbox ()
201
+ super ()._add_text_to_needs_change_comment (
202
+ super ().kb_revision_test_data ['needs_change_message' ]
203
+ )
204
+
205
+ if ready_for_l10n :
206
+ super ()._check_ready_for_localization_checkbox ()
207
+
208
+ super ()._click_accept_revision_accept_button ()
209
+
210
+ def submit_new_kb_revision (self ,
211
+ keywords = None ,
212
+ search_result_summary = None ,
213
+ content = None ,
214
+ expiry_date = None ,
215
+ changes_description = None ,
216
+ is_admin = False ,
217
+ approve_revision = False
218
+ ) -> dict [str , Any ]:
219
+
220
+ super ()._click_on_edit_article_option ()
221
+
222
+ # Only admin accounts can update article keywords.
223
+ if is_admin :
224
+ # Keywords step.
225
+ if keywords is None :
226
+ super ()._fill_edit_article_keywords_field (
227
+ self .kb_article_test_data ['updated_keywords' ]
228
+ )
229
+ else :
230
+ super ()._fill_edit_article_keywords_field (keywords )
231
+
232
+ # Search Result Summary step.
233
+ if search_result_summary is None :
234
+ super ()._fill_edit_article_search_result_summary_field (
235
+ self .kb_article_test_data ['updated_search_result_summary' ]
236
+ )
237
+ else :
238
+ super ()._fill_edit_article_search_result_summary_field (search_result_summary )
239
+
240
+ # Content step.
241
+ if content is None :
242
+ super ()._fill_edit_article_content_field (
243
+ self .kb_article_test_data ['updated_article_content' ]
244
+ )
245
+ else :
246
+ super ()._fill_edit_article_content_field (content )
247
+
248
+ # Expiry date step.
249
+ if expiry_date is None :
250
+ super ()._fill_edit_article_expiry_date (
251
+ self .kb_article_test_data ['updated_expiry_date' ]
252
+ )
253
+ else :
254
+ super ()._fill_edit_article_expiry_date (expiry_date )
255
+
256
+ # Submitting for preview steps
257
+ super ()._click_submit_for_review_button ()
258
+
259
+ if changes_description is None :
260
+ super ()._fill_edit_article_changes_panel_comment (
261
+ self .kb_article_test_data ['changes_description' ]
262
+ )
263
+ else :
264
+ super ()._fill_edit_article_changes_panel_comment (changes_description )
265
+
266
+ super ()._click_edit_article_changes_panel_submit_button ()
267
+
268
+ revision_id = super ()._get_last_revision_id ()
269
+
270
+ if approve_revision :
271
+ self .approve_kb_revision (revision_id )
272
+
273
+ return {"revision_id" : revision_id ,
274
+ "changes_description" : self .kb_article_test_data ['changes_description' ]
154
275
}
0 commit comments